package org.dftproject.genesis.ui.actions;

import org.dftproject.genesis.ui.Activator;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.dialogs.PreferencesUtil;

public class PreferencesAction extends Action {
	
	private final IWorkbenchWindow window;
	
	public PreferencesAction(IWorkbenchWindow window, String label) {
		this.window = window;
		setText(label);
		setId("preferences");
		setActionDefinitionId("preferences");
		setImageDescriptor(Activator.getImageDescriptor("icons/cog.png"));
	}
	
	@Override
	public void run() {
		if (window != null) {
			PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(window.getShell(), null, null, null);
			dialog.open();
		}
	}
	
}
